/*
* @Author: lenovo
* @Date:   2018-10-30 00:36:37
* @Last Modified by:   lenovo
* @Last Modified time: 2018-11-01 18:22:19
*/
/*const path = require('path')
//这个配置文件，起始就是一个JS文件，通过NODE 中的模块操作，向外暴露一个配置对象
module.exports = {
	entry: path.join(__dirname,'src/js/main.js'),
	output:{
		path: path.join(__dirname, 'dist'),
		filename: 'bundle.js'
	}
}*/
// 新版配置
var path = require('path');
//导入在内存中生成HTML页面的插件
var webpack = require('webpack');
//只要是插件都要放到plugins中去
//自动在内存中根据指定的页面生成一个内存页面，自动打包好了bundle,js追加到页面中去。
var htmlWebpackPlugin = require('html-webpack-plugin');

var { VueLoaderPlugin } = require('vue-loader');

module.exports = {
  mode: 'development',
  entry: path.join(__dirname,'src/js/main.js'),
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: 'bundle.js'
  },
 /* devServer: {
  	open: true,
  	port: 3000,
  	contentBase: 'src/js',
  	hot: true
  },
  */
plugins:[
  	// new webpack.HotModuleReplacementPlugin()第二种配置方法
  	new htmlWebpackPlugin({
  		template: path.resolve(__dirname, 'src/js/index.html'),
  		filename: 'index.html'
  	}),
    new VueLoaderPlugin()
  ],
  module:{
  	rules: [
  		{ test:/\.css$/, use: ["style-loader","css-loader"]},
  		{ test:/\.less$/, use: ['style-loader', 'css-loader','less-loader']},
  		{ test:/\.scss$/, use: ['style-loader', 'css-loader', 'sass-loader']},
  		{ test:/\.(jpg|png|gif|bmp|jpeg)$/, use: 'url-loader?limit=455,096&name=[hash:8]-[name].[ext]'},
  		{ test:/\.(ttf|eot|svg|woff|woff2)$/, use:'url-loader'},
  		{ test:/\.js$/, use:'babel-loader', exclude:/node_modules/},
      { test:/\.vue$/, use: 'vue-loader'}
  	]
  },
  resolve: {
    alias: { //修改Vue被导入时候的包的路径
      "vue$": "vue/dist/vue.js"
    }
  }
};
